var netcore = require('../../../utils/network.js')
var tripleDes = require('../../../utils/CKCrypto.js')
var comm=require('../../../utils/comm_util.js')
function getToutiao(_type,pageNum, callBack) {
  var map = new Map();
  map.set("model", _type);
  map.set("currentPage", pageNum)
  netcore.requestPost("news/getNews.do", map, function (data) {
    if (data){
      data.forEach(function(item){
        item.date = comm.formatDateInDay(item.date)
      })
    }
    callBack(data)
  }, function (code, errMsg) {
    wx.showToast({
      title: "" + errMsg,
    })
  })
}
function getNewInfo(_id,callBack){
  var map = new Map();
  map.set("id", tripleDes.enCode(_id));
  netcore.requestPost("news/getDetail.do", map, function (data) {
    callBack(data)
  }, function (code, errMsg) {
    wx.showToast({
      title: "" + errMsg,
    })
  })
}
function report(_id){
  var map = new Map();
  map.set("id", tripleDes.enCode(_id));
  netcore.requestPostNoLoading("news/rePort.do", map, function (data) {
    console.log("report success")
  }, function (code, errMsg) {
    wx.showToast({
      title: "" + errMsg,
    })
  })
}
module.exports = {
  getToutiao: getToutiao,
  getNewInfo: getNewInfo,
  report: report
}